package com.szh.zx.java8.day01;

import com.szh.zx.java8.POJO.Employee;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
* 通过实际案例进行训练，lambda表达式的使用
* */
public class TestLambda3 {
	List<Employee> employees = Arrays.asList(
			new Employee("张三1",12,2222),
			new Employee("张三2",12,2222),
			new Employee("张三3",40,2222),
			new Employee("张三4",12,22222),
			new Employee("张三5",12,2222)
	);
	
	public  void test1(){
		Collections.sort(employees,(e1,e2)->{
			if (e1.getAge() == e2.getAge()){
				return e1.getName().compareTo(e2.getName());
			}else {
				return Integer.compare(e1.getAge(),e2.getAge());
			}
		});
		for (Employee employee : employees) {
			System.out.println(employee);
		}
	}
	// 需求：用于处理字符串
	public String strHandler(String string, MyFunction myFunction){
		return myFunction.getValue(string);
	}
	// 测试一下
	
	public void test2(){
		String handler = strHandler("\t\t\t 我方见到你的仓库", str -> str.trim());
		System.out.println(handler);
		String ddddddd = strHandler("ddddddd", (str) -> str.toUpperCase());
		System.out.println(ddddddd);
	}
}
